<?php
namespace bx\controllers;

use yii\web\Controller;
use common\models\bx\BxInfo;
use yii\data\Pagination;

class DefaultController extends Controller
{
    public $layout = false;
    
    public function actionIndex()
    {
        $request = \Yii::$app->request;
        $pageSize = $request->get('page_size', 50);
        
        $where = array('status' => 2);
        $bxObj = BxInfo::find();
        $count = $bxObj->where($where)->count();
        $pagination = new Pagination(['totalCount' => $count, 'pageSize' => $pageSize]);
        $bxList = $bxObj->where($where)->orderBy( 'is_top desc, id desc' )->offset( $pagination->offset )->limit( $pagination->limit )->asArray()->all();
        
        $data = array(
            'bxList' => $bxList
        );
        
        return $this->render("index", $data);
    }
}